package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.OpportunityFocusDao;
import com.xbongbong.saas.domain.entity.OpportunityFocusEntity;
import com.xbongbong.saas.model.OpportunityFocusModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/1 10:29
 * @since v1.0
 */
@Service("opportunityFocusModel")
public class OpportunityFocusModelImpl implements OpportunityFocusModel {
    @Resource
    private OpportunityFocusDao opportunityFocusDao;

    @Override
    public Integer insert(OpportunityFocusEntity entity) throws XbbException {
        return opportunityFocusDao.insert(entity);
    }

    @Override
    public Integer update(OpportunityFocusEntity entity) throws XbbException {
        return opportunityFocusDao.update(entity);
    }

    @Override
    public List<OpportunityFocusEntity> findEntitys(Map<String, Object> param) {
        return opportunityFocusDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return null;
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public List<Long> getShareOpportunityIdList(String corpid) {
        return opportunityFocusDao.getShareOpportunityIdList(corpid);
    }

    @Override
    public List<Long> getNoShareOpportunityIdList(String userId, String corpid) {
        return opportunityFocusDao.getNoShareOpportunityIdList(userId,corpid);
    }

    @Override
    public OpportunityFocusEntity getByOpportunityId(Long dataId, String userId, String corpid) {
        return opportunityFocusDao.getByOpportunityId(dataId,userId,corpid);
    }

    @Override
    public Long save(OpportunityFocusEntity opportunityFocusEntity) throws XbbException{
        if (opportunityFocusEntity.getId() == null){
            insert(opportunityFocusEntity);
        }else {
            update(opportunityFocusEntity);
        }
        return opportunityFocusEntity.getId();
    }

    @Override
    public void unFocusBatch(Long dataId, String corpid) {
        opportunityFocusDao.unFocusBatch(dataId,corpid);
    }
}
